﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
namespace Web.admin.web
{
    public partial class Permission : System.Web.UI.Page
    {
        //BLL.UserClass userClass = new BLL.UserClass();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack) {
                //ddl_UserClass_Bind();
                //CBList_Bind();
            }

        }
        ///// <summary>
        ///// 保存按钮点击事件，更新权限
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="e"></param>
        //protected void btn_Save_Click(object sender, EventArgs e) {
        //    StringBuilder sbd = new StringBuilder();
        //        for (int i = 0; i < 27; i++) {
        //            CheckBox cb = (CheckBox)form1.FindControl("cb"+i);
        //            if (cb.Checked) {
        //                sbd.Append(i + ",");
        //            }
        //        }
        //    string permission = sbd.ToString();
        //    int id = Convert.ToInt32(ddl_UserClass.SelectedValue);
        //    int k = userClass.updatePermission(id, permission);
        //    if (k > 0)
        //    {
        //        Response.Write("<script>alert('更新权限成功')</script>");
        //    }
        //    else
        //        Response.Write("<script>alert('更新权限失败')</script>");
        //}
        ///// <summary>
        ///// 对ddl_UserClass下拉列表的绑定
        ///// </summary>
        //protected void ddl_UserClass_Bind() {
        //    ddl_UserClass.DataSource = userClass.GetUserClass();
        //    ddl_UserClass.DataTextField = "UserTitle";
        //    ddl_UserClass.DataValueField = "UserId";
        //    ddl_UserClass.DataBind();
        //}
        ///// <summary>
        ///// 用户类别文本改变事件
        ///// </summary>
        ///// <param name="sender"></param>
        ///// <param name="e"></param>
        //protected void ddl_UserClass_Change(object sender, EventArgs e) {
        //    for (int i = 0; i < 27; i++) {
        //        CheckBox cb = (CheckBox)form1.FindControl("cb" + i) as CheckBox;
        //        cb.Checked = false; 
        //    }
        //        Session["PermissionValue"] = ddl_UserClass.SelectedValue;
        //    CBList_Bind();
        //}
        //protected void CBList_Bind() {
        //    int id;
        //    if (Session["PermissionValue"]!= null && int.TryParse(Session["PermissionValue"].ToString(), out id))
        //    {}
        //    else
        //    {
        //        ddl_UserClass.SelectedValue = "1";
        //        id = 1;
        //    }
        //    string permissionStr = new DbCommon.DbHelper().GetSingleItem("UserClass", "UserPermission", "UserId=" + id).ToString();
        //    string[] strArry = DbCommon.Utils.SplitString(permissionStr, ',');
        //    foreach (string str in strArry) {
        //        if (!string.IsNullOrEmpty(str))
        //        {
        //            CheckBox cb = (CheckBox)form1.FindControl("cb" + str);
        //            cb.Checked = true;
        //        }
        //    }
        //}
    }
}